package com.example.sqlite;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private MyDatabaseHelper helper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        helper = new MyDatabaseHelper(this,"BookStore.db",null,2);

        findViewById(R.id.create_database).setOnClickListener(this);
        findViewById(R.id.insert).setOnClickListener(this);
        findViewById(R.id.delete).setOnClickListener(this);
        findViewById(R.id.update).setOnClickListener(this);
        findViewById(R.id.select).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id){
            case R.id.create_database:
                helper.getWritableDatabase();
                break;
            case R.id.insert:
                SQLiteDatabase db = helper.getWritableDatabase();
                db.execSQL("insert into Book (name,author,pages,price) values (?, ?, ?, ?)",new String[]{"aa","b","454","10.00"});
                break;
            case R.id.delete:

                break;
            case R.id.update:

                break;
            case R.id.select:

                break;
        }
    }
}